package com.example.lenovo.broadnotifytest106lixi;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    private EditText et;
    private Button b1,b2;
    private String UNIQUE_STRING="com.example.lenovo.broadnotifytest106lixi";
    private View.OnClickListener listener= new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.button:
                    Intent intent=new Intent(UNIQUE_STRING);
                    intent.putExtra("para2",et.getText().toString());
                            sendBroadcast(intent);
                    break;
                case R.id.button2:
                    MyReceiver.manager.cancel(MyReceiver.notifyID);
                    break;
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        unit();
    }

    private void unit() {
        et=(EditText) findViewById(R.id.editText);
        b1=(Button)findViewById(R.id.button);
        b2=(Button)findViewById(R.id.button2);
b1.setOnClickListener(listener);
        b2.setOnClickListener(listener);

    }
}
